home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / telecomm / misc / rsp37_3.lha / rshell-protector.s < prev    next >
Encoding:
Text File  |  1994-11-18  |  6.0 KB  |  271 lines

  1. ****************************************************
  2. * DISCLAIMER: we (Lunkwill & Skywalker) take no    *
  3. * responsibility for damages on your brain, Amiga, *
  4. * mother-in-law or whatever directly or indirectly *
  5. * caused by reading, executing, disassembling,     *
  6. * archiving or deleting this sourcecode or         *
  7. * executable. This code was done entirely under    *
  8. * heavy influence of THC - you have been warned!   *
  9. ****************************************************
  10.  
  11.  
  12. OpenLibrary    = -552
  13. CloseLibrary    = -414
  14. Forbid        = -132
  15. Permit        = -138
  16. SetFunction    = -420
  17. Wait        = -318
  18.  
  19. GetVar        = -906
  20. Output        = -60
  21. Write        = -48
  22. ReadArgs    = -798
  23. FreeArgs    = -858
  24.  
  25. OpenScreen        = -198        
  26. OpenScreenTagList    = -612
  27. OpenWindow        = -204        
  28. OpenWindowTagList    = -606
  29.  
  30. SIGBREAKF_CTRL_C    = (1<<12)
  31. GVF_LOCAL_ONLY        = $200
  32.  
  33.     move.l    4,a6
  34.     lea    IntuiName(pc),a1
  35.     moveq    #37,d0
  36.     jsr    OpenLibrary(a6)
  37.     move.l    d0,IntuiBase
  38.     beq.w    NoIntui            ;poooooor amiga! no intuition :-(
  39.  
  40.     lea    DosName(pc),a1
  41.     moveq    #36,d0
  42.     jsr    OpenLibrary(a6)
  43.     move.l    d0,a6
  44.     beq.w    NoDos            ;no dos either? is it NT?
  45.     move.l    d0,DosBase
  46.  
  47.     lea    ArgTemplate(pc),a0
  48.     move.l    a0,d1
  49.     lea    ArgPtr(pc),a0
  50.     move.l    a0,d2
  51.     moveq    #0,d3
  52.     jsr    ReadArgs(a6)
  53.     move.l    d0,ArgStruct
  54.     beq.w    WrongArgs        ;shtupid bugga! enta sum variable!
  55.  
  56.     move.l    4,a6
  57.     jsr    Forbid(a6)        ;stop it! it's me, patching. only me!!!
  58.  
  59.     move.l    IntuiBase(pc),a1
  60.     suba.l    a0,a0
  61.     move.w    #OpenScreen,a0
  62.     lea    NewOpenScreen(pc),a2
  63.     move.l    a2,d0
  64.     jsr    SetFunction(a6)        ;one patch fo' momma
  65.     move.l    d0,OldOpenScreen
  66.  
  67.     move.l    IntuiBase(pc),a1
  68.     suba.l    a0,a0
  69.     move.w    #OpenScreenTagList,a0
  70.     lea    NewOpenScreenTagList(pc),a2
  71.     move.l    a2,d0
  72.     jsr    SetFunction(a6)        ;one fo' daddy
  73.     move.l    d0,OldOpenScreenTagList
  74.  
  75.     move.l    IntuiBase(pc),a1
  76.     suba.l    a0,a0
  77.     move.w    #OpenWindow,a0
  78.     lea    NewOpenWindow(pc),a2
  79.     move.l    a2,d0
  80.     jsr    SetFunction(a6)        ;one fo' littl sis
  81.     move.l    d0,OldOpenWindow
  82.  
  83.     move.l    IntuiBase(pc),a1
  84.     suba.l    a0,a0
  85.     move.w    #OpenWindowTagList,a0
  86.     lea    NewOpenWindowTagList(pc),a2
  87.     move.l    a2,d0
  88.     jsr    SetFunction(a6)        ;and...c'mon...one fo' ya amiga!
  89.     move.l    d0,OldOpenWindowTagList
  90.  
  91.     jsr    Permit(a6)        ;go on there...
  92.  
  93.     bsr.w    PrintC            ;sum babble to da shell
  94.     jsr    Output(a6)
  95.     move.l    d0,d1
  96.     lea    Installed_Msg(pc),a0    ;more babble
  97.     move.l    a0,d2
  98.     moveq    #Installed_Len,d3
  99.     jsr    Write(a6)
  100.     
  101.     move.l    4,a6
  102.     move.l    #SIGBREAKF_CTRL_C,d0    ;why r-we-wai-tin'?
  103.     jsr    Wait(a6)        ;we r suffo-ca-tin'!
  104. ;Ctrl-C received            ;sucka wanna quit :-(
  105.     move.l    IntuiBase(pc),a1
  106.     suba.l    a0,a0
  107.     move.w    #OpenScreenTagList,a0
  108.     move.l    OldOpenScreenTagList(pc),d0
  109.     jsr    SetFunction(a6)        ;if you
  110.  
  111.     move.l    IntuiBase(pc),a1
  112.     suba.l    a0,a0
  113.     move.w    #OpenScreen,a0
  114.     move.l    OldOpenScreen(pc),d0
  115.     jsr    SetFunction(a6)        ;really wanna
  116.  
  117.     move.l    IntuiBase(pc),a1
  118.     suba.l    a0,a0
  119.     move.w    #OpenWindowTagList,a0
  120.     move.l    OldOpenWindowTagList(pc),d0
  121.     jsr    SetFunction(a6)        ;quit...
  122.     
  123.     move.l    IntuiBase(pc),a1
  124.     suba.l    a0,a0
  125.     move.w    #OpenWindow,a0
  126.     move.l    OldOpenWindow(pc),d0
  127.     jsr    SetFunction(a6)        ;ok then!
  128.  
  129.     bsr.w    PrintC            ;neverendin' babble
  130.     jsr    Output(a6)
  131.     move.l    d0,d1
  132.     lea    Removed_Msg(pc),a0    ;will it neva end?
  133.     move.l    a0,d2
  134.     moveq    #Removed_Len,d3
  135.     pea    CleanUp(pc)
  136.     jmp    Write(a6)
  137.  
  138. WrongArgs:
  139.     jsr    Output(a6)        ;i knew it!
  140.     move.l    d0,d1
  141.     lea    WrongArgs_Msg(pc),a0
  142.     move.l    a0,d2
  143.     move.l    #WrongArgs_Len,d3
  144.     jsr    Write(a6)        ;there's...there's more...teeexxxt!!!
  145.  
  146. CleanUp:
  147.     move.l    DosBase(pc),a6
  148.     move.l    ArgStruct(pc),d1
  149.     jsr    FreeArgs(a6)        ;piss off args!
  150.  
  151.     move.l    a6,a1
  152.     move.l    4,a6
  153.     jsr    CloseLibrary(a6)    ;and dos
  154. NoDos:
  155.     move.l    IntuiBase(pc),a1
  156.     jsr    CloseLibrary(a6)    ;and intuition
  157. NoIntui:
  158.     moveq    #0,d0
  159.     rts                ;cya!
  160.  
  161.  
  162. NewOpenScreen:
  163.     movem.l    d0-d4/a0-a1/a6,-(sp)
  164.     jsr    CheckVar        ;we have a variable here?
  165.     bne.s    OpenScreen_OK        ;no -> go on open it!
  166.     movem.l    (sp)+,d0-d4/a0-a1/a6
  167.     moveq    #0,d0            ;else quit
  168.     rts                ;returning FALSE
  169. OpenScreen_OK:
  170.     movem.l    (sp)+,d0-d4/a0-a1/a6
  171.     move.l    OldOpenScreen(pc),-(sp)
  172.     rts
  173.  
  174. NewOpenScreenTaglist:
  175.     movem.l    d0-d4/a0-a1/a6,-(sp)
  176.     jsr    CheckVar
  177.     bne.s    OpenScreenTaglist_OK
  178.     movem.l    (sp)+,d0-d4/a0-a1/a6
  179.     moveq    #0,d0
  180.     rts
  181. OpenScreenTaglist_OK:
  182.     movem.l    (sp)+,d0-d4/a0-a1/a6
  183.     move.l    OldOpenScreenTaglist(pc),-(sp)
  184.     rts
  185.  
  186. NewOpenWindow:
  187.     movem.l    d0-d4/a0-a1/a6,-(sp)
  188.     jsr    CheckVar
  189.     bne.s    OpenWindow_OK
  190.     movem.l    (sp)+,d0-d4/a0-a1/a6
  191.     moveq    #0,d0
  192.     rts
  193. OpenWindow_OK:
  194.     movem.l    (sp)+,d0-d4/a0-a1/a6
  195.     move.l    OldOpenWindow(pc),-(sp)
  196.     rts
  197.  
  198. NewOpenWindowTaglist:
  199.     movem.l    d0-d4/a0-a1/a6,-(sp)
  200.     jsr    CheckVar
  201.     bne.s    OpenWindowTaglist_OK
  202.     movem.l    (sp)+,d0-d4/a0-a1/a6
  203.     moveq    #0,d0
  204.     rts
  205. OpenWindowTaglist_OK:
  206.     movem.l    (sp)+,d0-d4/a0-a1/a6
  207.     move.l    OldOpenWindowTaglist(pc),-(sp)
  208.     rts
  209.  
  210. CheckVar:
  211.     move.l    DosBase(pc),a6        ;illegal tricks in here :-(
  212.     move.l    ArgPtr(pc),a0
  213.     move.l    a0,d1
  214.     lea    VarBuf(pc),a0
  215.     move.l    a0,d2
  216.     moveq    #1,d3
  217.     move.l    #GVF_LOCAL_ONLY,d4    ;only want var for our process
  218.     jsr    GetVar(a6)        ;we shouldn't do that inside an
  219.     cmpi.l    #-1,d0            ;intuition fuction...
  220.     bne.s    CV_IOSer        ;got var? -> I/O is ASCII only
  221.     moveq    #1,d0
  222.     rts
  223. CV_IOSer:
  224.     move.l    DosBase(pc),a6
  225.     jsr    Output(a6)        ;blah...error...no window
  226.     move.l    d0,d1
  227.     lea    ErrorNoDisplay_Msg(pc),a0
  228.     move.l    a0,d2
  229.     move.l    #ErrorNoDisplay_Len,d3
  230.     jsr    Write(a6)        ;hey, usa!
  231.     moveq    #0,d0
  232.     rts
  233.  
  234. PrintC:
  235.     move.l    DosBase(pc),a6        ;side fx? waddsat?
  236.     jsr    Output(a6)
  237.     move.l    d0,d1
  238.     lea    Copyright_Msg(pc),a0
  239.     move.l    a0,d2
  240.     move.l    #Copyright_Len,d3
  241.     jsr    Write(a6)
  242.     rts
  243.  
  244. OldOpenscreen:        dc.l    0
  245. OldOpenscreentaglist:    dc.l    0
  246. OldOpenwindow:        dc.l    0
  247. OldOpenwindowtaglist:    dc.l    0
  248. IntuiBase:        dc.l    0
  249. DosBase:        dc.l    0
  250. ArgPtr:            dc.l    0
  251. ArgStruct:        dc.l    0
  252. VarBuf:            dc.w    0
  253. ArgTemplate:        dc.b    "Variable/A",0
  254. IntuiName:        dc.b    "intuition.library",0
  255. DosName:        dc.b    "dos.library",0
  256. WrongArgs_Msg:        dc.b    "Usage: rshell-protector <variable-name>",$a
  257. WrongArgs_Len:        EQU    *-WrongArgs_Msg
  258. ErrorNoDisplay_Msg:    dc.b    $7,"You are using an ASCII-only terminal.",$a
  259.             dc.b    "Could not open intuition GUI!",$a
  260. ErrorNoDisplay_Len:    EQU    *-ErrorNoDisplay_Msg
  261. Copyright_Msg:        dc.b    $1b,"[32mRemoteShell-Protector V37.3",$a
  262.             dc.b    "(L) 1994 by Lunkwill & Skywalker",$a
  263.             dc.b    $1b,"[0mPatches "
  264. Copyright_Len:        EQU    *-Copyright_Msg
  265. Installed_Msg:        dc.b    "installed!",$a
  266. Installed_Len:        EQU    *-Installed_Msg
  267. Removed_Msg:        dc.b    "removed!",$a
  268. Removed_Len:        EQU    *-Removed_Msg
  269.  
  270. ;hehe, and still under 1K !!!
  271.